package com.amado.course42Socket.tcp;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.net.Socket;

public class S02HelloSocketStreamClient {
    public static void main(String[] args) {
    	//服务端的IP地址
        String host = "localhost";
        //服务端的端口号
        int port = 8888;
        //新建一个Socket对照
        Socket socket = null;
		try {
			socket = new Socket(host, port);
		} catch (IOException e) {
			e.printStackTrace();
		}
        //得到一个输入流，读取数据
        BufferedReader lineNumberReader = null;
		try {
			lineNumberReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
        while(true){
        	try {
				System.out.println(lineNumberReader.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        }
        
    }
}